﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using ZYO;

namespace WebRoleIching
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DateTime now = DateTime.UtcNow.AddHours(8);
            ZYDateTime zdt = new ZYDateTime(now);
            this.CalendarDate.SelectedDate = now;

            this.DateLabel.Text = zdt.Xml.年.枚举值.ToString() + " ";
            this.DateLabel.Text += zdt.Xml.月.枚举值.ToString() + " ";
            this.DateLabel.Text += zdt.Xml.日.枚举值.ToString() + " ";
            this.DateLabel.Text += zdt.Xml.时.枚举值.ToString() + " ";

        }


        protected void ButtonStart_Click(object sender, EventArgs e)
        {
            ZYO.Persistence.Obj.e起卦方法 method = ZYO.Persistence.Obj.e起卦方法.测字;

            string strGua = this.tbGuaString.Text.Trim();
            if (System.Text.RegularExpressions.Regex.IsMatch(strGua, @"^[0-3]{6}$"))
            {
                method = ZYO.Persistence.Obj.e起卦方法.摇卦;

            }
            else if (System.Text.RegularExpressions.Regex.IsMatch(strGua, @"^(19|20)\d\d[- /.](0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])$"))
            {
                method = ZYO.Persistence.Obj.e起卦方法.时间;
            }
            else if (System.Text.RegularExpressions.Regex.IsMatch(strGua, @"^\d+;\d+$"))
            {
                method = ZYO.Persistence.Obj.e起卦方法.数字;
            }
            else
            {
                method = ZYO.Persistence.Obj.e起卦方法.测字;
            }

            class六爻起卦 gua = new class六爻起卦(method, this.CalendarDate.SelectedDate, strGua, this.ddlAsk.SelectedItem.Text);

            this.output.Text = gua.Xml.文件.UI;
        }

        protected void CalendarDate_SelectionChanged(object sender, EventArgs e)
        {
            ZYDateTime zdt = new ZYDateTime(this.CalendarDate.SelectedDate);

            this.DateLabel.Text = zdt.Xml.年.枚举值.ToString() + " ";
            this.DateLabel.Text += zdt.Xml.月.枚举值.ToString() + " ";
            this.DateLabel.Text += zdt.Xml.日.枚举值.ToString() + " ";
            this.DateLabel.Text += zdt.Xml.时.枚举值.ToString() + " ";

        }
    }
}
